/**
 * 1、横表、竖表的生成
 * 2、多实例操作按钮的事件绑定及事件响应
 * 3、界面元素的赋值
 * 4、界面元素值的更新
 * 5、界面元素值的保存
 */
var HTML = ( function () {

  var trEvent = " onmouseover='tr_over(this)' onmouseout='tr_out(this)' ", //
    inputOnBlurEvent = " onmouseout='top.HTML.update(this)' onkeyup='top.HTML.update(this)' ";
  // 立即执行，只计算一次
  ( function () {
    if (top.isMobile()) {
      trEvent = " onmouseover='tr_over_mobile(this)' onmouseout='tr_out_mobile(this)' ";
      inputOnBlurEvent = " onblur='top.HTML.update(this)' ";
    }
  }());

  /**
   * 多实例的横向表格生成
   * @param{Object} $, 子页面的$对象；
   * @param{String} showPos, 显示位置的DOM id；
   * @param{Array} structIDArr, 多实例结构体ID集合
   */
  function hTable($, showPos, structIDArr) {
    $("#" + showPos).empty();
    var i = 0, len = structIDArr.length, structID = "", htm = "";
    for (i = 0; i < len; i += 1) {
      structID = structIDArr[i];
      htm = createInnerBox(structID);
      $("#" + showPos).append(htm);
    }
  }

  function createInnerBox(structID) {
    var structDesc = parent.localDB.T_search("c_param", "StructID", structID), //
      showStructName = "", htm = [], canBeAdd = Struct.isMulInstanceAddable(structDesc), //
      structName = structDesc[0][top.c_paramRowIndex.StructName], //
      hStructObj = {}, structForAdd = {}, StructIDIndex = top.c_paramRowIndex.StructID;

    if (top.Language === "EN") {
      showStructName = structDesc[0][top.c_paramRowIndex.StructName];
    } else {
      showStructName = structDesc[0][top.c_paramRowIndex.StructCnName];
      if (showStructName === "") {
        showStructName = structDesc[0][top.c_paramRowIndex.StructName];
      }
    }

    hStructObj = top.Struct.getStructByName(structName);
    CurrentStructs.push(hStructObj);
    if (canBeAdd) {
      //给CurrentStructs.push()一个用于Add操作的结构体
      structForAdd = top.objectClone(hStructObj);
      top.Struct.toChangeable(structForAdd.structDesc);
      Struct.setNewStructID(structForAdd.structDesc, structID + "Add");
      CurrentStructs.push(structForAdd);
      CurrentStructs.name_valInit(structForAdd.structDesc[0][StructIDIndex]);
    }

    htm.push('<div class="infoTitle"><label>', showStructName, '</label></div><div class="innerBox" >');
    htm.push(createOptionBar(structID, canBeAdd));
    htm.push('<div class="parameterGridBox" style="overflow: auto;min-height:0%; _width:800px;">');
    htm.push('<table style="margin-bottom: 15px;" border="0" cellspacing="0" cellpadding="0" class="parameterGrid parameterGridMulti" id="instanceBox_', structID, '">');
    htm.push(createHTable(hStructObj.structDesc, canBeAdd), '</table></div>');
    if (canBeAdd) {
      htm.push('<div class="parameterGridBox" id="multiInstanceAddDiv_', structID, //
        '" style="overflow-y: auto; display:none;"><div class="infoTitle"><label>', top.T.BTN.Add, '</label></div>', //
        '<div id="multiInstanceAdd_', structID, '"><table id="multiInstanceAddTable_', structID, '" width="100%" border="0" ', //
        ' cellspacing="0" cellpadding="0" class="parameterGrid"></table>', //
        '<div class="btnBar" id="btnBar', structID, '" style="position:static; width: 50%; margin: 0px auto;">', //
        '<a class="btn1" href="#btnBar', structID, '" structID="', structID, '" onclick="multiAddConfirm(this);"><span>', top.T.BTN.Confirm, '</span></a>', //
        '<a class="btn1" href="#btnBar', structID, '" structID="', structID, '" onclick="multiAddCancel(this);"><span>', top.T.BTN.Cancel, '</span></a>');
      if (top.USER.hasModule(top.Branch.Modules.Help)) {
        htm.push('<a class="btn1" href="#btnBar', structID, '" structID="', structID, '" onclick="multiHelp(this);"><span>', top.T.BTN.Help, '</span></a></div></div>', //
          '<div id="tips_', structID, '" class="paramTips multi"></div></div>');
      } else {
        htm.push('</div></div>');
      }
    }
    htm.push("</div><br/><br/>");
    return htm.join("");
  }

  function createOptionBar(structID, canBeAdd) {
    var htm = ['<div class="tabBar"  id="tabBar', structID, '">'];
    if (!isAllHide(structID) || canBeAdd) {
      htm.push('<a class="btn1" href="#tabBar', structID, '" onclick="multiSave(this);" structID="', structID, //
        '"><span>', top.T.BTN.Save, '</span></a>');
    }
    if (canBeAdd) {
      htm.push('<a class="btn1" href="#tabBar', structID, '" onclick="multiAdd(this);" structID="', structID, '"><span>', top.T.BTN.Add, '</span></a>', //
        '<a class="btn1" href="#tabBar', structID, '" onclick="multiDelect(this);" structID="', structID, '"><span>', top.T.BTN.Delete, '</span></a>');
    }
    htm.push('<a class="btn1" href="#tabBar', structID, '" onclick="multiRefresh(this);" structID="', structID, '"><span>', top.T.BTN.Refresh, '</span></a>');
    htm.push('<span id="pageSelectorSpan_' + structID + '">');
    htm.push(createPageSelector(structID));
    htm.push('</span></div>');
    return htm.join("");
  }

  function isAllHide(structID) {
    var structDesc = parent.localDB.T_search("c_param", "StructID", structID), //
      WebTypeIndex = top.c_paramRowIndex.WebType, i = 0, result = true;

    for (i = 0; i < structDesc.length; i += 1) {
      var webType = structDesc[i][WebTypeIndex], //
        enable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20], //
        disable = [10, 11, 12, 13, 14, 15, 16, 17, 8, 9, 20];

      if (!$.inArray(webType, enable)) {//在返回-1，不在返回1
        result = false;
        break;
      }
    }
    return result;
  }

  function createPageSelector(structID, pageNum) {
    var hStructObj = CurrentStructs.get(structID), htm = [""], //
      rows = (hStructObj.name_val.length / hStructObj.structDesc.length), pages = 0, i = 0;
    if (rows > G.PageRows) {
      pages = rows / G.PageRows;
      if ((rows % G.PageRows) > 0) {
        pages += 1;
      }
      htm.push('&nbsp;&nbsp;&nbsp;', top.T.ParamView.PageN, '&nbsp;<select id="pageSelector_', structID, '" structID="', structID, //
        '" onchange="gotoPage(this)">');
      for (i = 1; i <= pages; i += 1) {
        if (pageNum == i) {
          htm.push('<option selected="selected" value="' + i + '">' + i + '</option>');
        } else {
          htm.push('<option value="' + i + '">' + i + '</option>');
        }
      }
      htm.push('</select>&nbsp;', top.T.ParamView.PageN2);
    }
    return htm.join("");
  }

  function createWebTypeDesc(row, column, desc) {
    var webType = $.trim(desc[top.c_paramRowIndex.WebType]) === "" ? 0 : window.parseInt(desc[top.c_paramRowIndex.WebType], 10), //
      webTips = Transfer.parseDbColumn(desc[top.c_paramRowIndex.Level]), descObj = {}, infos = [], tips = "", unique = false;

    descObj.cols = column;
    descObj.row = row;
    descObj.structDesc = desc;

    descObj.id = desc[top.c_paramRowIndex.StructID] + "_" + desc[top.c_paramRowIndex.MemberID] + "_" + row.toString();
    descObj.structName = desc[top.c_paramRowIndex.StructName];
    descObj.memberType = webType;

    descObj.name = desc[top.c_paramRowIndex.MemberName];
    descObj.structID = desc[top.c_paramRowIndex.StructID];
    descObj.memberID = desc[top.c_paramRowIndex.MemberID];
    descObj.proto = "";

    descObj.typeclass = "";
    descObj.parentType = "";

    infos = webTips.split('|');
    tips = "";

    if (top.Language === "EN") {
      if (infos.length >= 7 && infos[6].length >= 1) {
        tips = "title='" + infos[6] + "'";
      }
    } else {
      if (infos.length >= 2 && infos[1].length >= 1) {
        tips = "title='" + infos[1] + "'";
      }
    }
    descObj.tips = tips;

    if (infos.length >= 1 && infos[0].length >= 1) {
      descObj.Unit = "&nbsp;&nbsp;" + infos[0];
    } else {
      descObj.Unit = "";
    }

    // 多实例唯一性标识
    if (infos.length >= 6 && infos[5].length >= 1) {
      unique = (window.parseInt(infos[5], 10) === 1);
    } else {
      unique = false;
    }
    descObj.unique = unique;

    return descObj;
  }

  function createHTable(structDesc, canBeAdd, pageNum) {
    var structID = "", hStructObj = {}, //
      html = [], rows = 0, rCNT = 0, odd_even = "even", //
      cols = 0, cLen = 0, webType = -1, webTips = "", desc = {}, infos = [], tips = "", //
      WebTypeIndex = top.c_paramRowIndex.WebType, //
      LevelIndex = top.c_paramRowIndex.Level, //
      MemberNameIndex = top.c_paramRowIndex.MemberName, //
      MemberIDIndex = top.c_paramRowIndex.MemberID, //
      StructIDIndex = top.c_paramRowIndex.StructID;

    structID = structDesc[0][StructIDIndex];
    hStructObj = CurrentStructs.get(structID);

    if (typeof (pageNum) === 'undefined') {
      pageNum = 1;
    }
    rCNT = (pageNum - 1) * G.PageRows;
    rows = hStructObj.name_val.length / hStructObj.sLength;
    if (rows > (rCNT + G.PageRows)) {
      rows = rCNT + G.PageRows;
    }

    for (rows; rCNT < rows; rCNT += 1) {
      odd_even = (rCNT % 2) === 1 ? "odd" : "even";
      html.push("<tr intance='", rCNT, "'", trEvent, ">");

      if (canBeAdd) {
        html.push(" <td> <input class='", structID, "_instance_select' instanceIndex='", //
          rCNT, "' type='checkbox' />  </td> ");
      }

      for (cols = 0, cLen = structDesc.length; cols < cLen; cols += 1) {
        webType = $.trim(structDesc[cols][WebTypeIndex]) === "" ? 0 : window.parseInt(structDesc[cols][WebTypeIndex], 10);
        webTips = Transfer.parseDbColumn(structDesc[cols][LevelIndex]);
        if (!top.USER.isAuthorised(top.USER.getStructLevel(webTips, "p")) || webType === -1) {
          continue;
        }

        desc = {};
        desc = createWebTypeDesc(rCNT, cols, structDesc[cols]);
        nowrap = "";
        if (webType === 10 || webType === 11) {
          nowrap = "nowrap='nowrap'";
        }
        html.push("<td ", nowrap, ">" + getDiv(webType, desc) + "</td>");
      }

      html.push("</tr>");
    }

    if (html.length === 0) {
      return ["<tr><td colspan='", hStructObj.sLength, "'>no instance</td></tr>"].join("");
    } else {
      return hTableTitle(structDesc, canBeAdd) + html.join("");
    }
  }

  /**
   * 生成多实例表头
   */
  function hTableTitle(structDesc, canBeAdd) {
    var title = ["<tr>"], tCNT = 0, len = 0, //
      infos = [], Unit, structID = "", webTips = "", //
      WebTypeIndex = top.c_paramRowIndex.WebType, //
      LevelIndex = top.c_paramRowIndex.Level, //
      MemberCnNameIndex = top.c_paramRowIndex.MemberCnName, //
      MemberNameIndex = top.c_paramRowIndex.MemberName, //
      StructIDIndex = top.c_paramRowIndex.StructID, //
      showMemberName = "";

    structID = structDesc[0][StructIDIndex];
    if (canBeAdd) {
      title.push("<th nowrap='nowrap'><input type='checkbox' structID='", //
        structID, "' onclick='selectAll(this);'/></th>");
    }

    for (tCNT = 0, len = structDesc.length; tCNT < len; tCNT += 1) {
      if (window.parseInt(structDesc[tCNT][WebTypeIndex], 10) === -1) {
        continue;
      }
      webTips = Transfer.parseDbColumn(structDesc[tCNT][LevelIndex]);
      if (!top.USER.isAuthorised(top.USER.getStructLevel(webTips, "p"))) {
        continue;
      }

      infos = webTips.split('|');
      Unit = "";
      if (infos.length >= 1 && infos[0].length >= 1) {
        Unit = "(" + infos[0] + ")";
      }

      if (top.Language === "EN") {
        showMemberName = structDesc[tCNT][MemberNameIndex];
      } else {
        showMemberName = $.trim(structDesc[tCNT][MemberCnNameIndex]) === "" ? //
          structDesc[tCNT][MemberNameIndex] : structDesc[tCNT][MemberCnNameIndex];
      }

      title.push("<th nowrap='nowrap'>", showMemberName, Unit, "</th>");
    }
    title.push("</tr>");

    return title.join("");
  }

  /**
   * 刷新横表,在用户执行刷新、添加、删除时需要更新表格
   * @param{Object} $,子页面的$对象；
   * @param{String} structID;
   *
   */
  function refreshHTable($, structID, pageNum) {
    top.CurrentStructs.refresh(structID);
    var selectorHtml = createPageSelector(structID, pageNum);
    $("#pageSelectorSpan_" + structID).empty().append(selectorHtml);
    page($, structID, pageNum);
  }

  /**
   * 多实例大数据时分页显示，定位显示多实例的页，只适用多实例
   * @param{Number} page number
   */
  function page($, structID, pageNum) {
    var structDesc = CurrentStructs.get(structID).structDesc, htm = '', //
      canBeAdd = Struct.isMulInstanceAddable(structDesc);

    htm = createHTable(structDesc, canBeAdd, pageNum);
    $("#instanceBox_" + structID).empty().append(htm);
  }

  /**
   * 创建竖向表格
   * @param {Object} structObj，结构体对象
   * @param {Boolean} [showAllParams],default:false,去除数据库配置的param Level值控制，全部显示
   */
  function vTable(structObj, showAllParams) {
    var structDesc = structObj.structDesc, desc = {}, allParamShow = false, html = [], /*isMulti = Struct.isMulInstance(structDesc),*/ //
      odd_even = "odd", i = 0, sLen = 0, valType = 0, infos = "", tips = "", MemberShowName = "", //
      primarryKeySym = "", colon = "", webTips = "", uniqueFrag = 0, //
      LevelIndex = top.c_paramRowIndex.Level, //
      WebTypeIndex = top.c_paramRowIndex.WebType, //
      MemberNameIndex = top.c_paramRowIndex.MemberName, //
      MemberIDIndex = top.c_paramRowIndex.MemberID, //
      MemberCnNameIndex = top.c_paramRowIndex.MemberCnName, //
      StructIDIndex = top.c_paramRowIndex.StructID, //
      StructNameIndex = top.c_paramRowIndex.StructName, //
      IsPrimaryKeyIndex = top.c_paramRowIndex.IsPrimaryKey;

    if (showAllParams) {
      allParamShow = showAllParams;
    }

    if (top.Language === "EN") {
      colon = " :&nbsp;&nbsp;&nbsp;";
    } else {
      colon = "：";
    }

    for (i = 0, sLen = structDesc.length; i < sLen; i += 1) {
      webTips = Transfer.parseDbColumn(structDesc[i][LevelIndex]);
      if (!top.USER.isAuthorised(top.USER.getStructLevel(webTips, "p")) && !allParamShow) {
        continue;
      }

      odd_even = (i % 2) === 1 ? "odd" : "even";
      valType = $.trim(structDesc[i][WebTypeIndex]) === "" ? 0 : window.parseInt(structDesc[i][WebTypeIndex], 10);

      desc = {};
      desc = createWebTypeDesc(0, i, structDesc[i]);

      if (top.Language === "EN") {
        //混合结构体中，由于StructDesc的MemberName经过修改的，不能用于英文版的显示
        if (structObj.memberNames) {
          MemberShowName = structObj.memberNames[i];
        } else {
          MemberShowName = structDesc[i][MemberNameIndex];
        }
      } else {
        if ($.trim(structDesc[i][MemberCnNameIndex]) === "") {
          //混合结构体中，由于StructDesc的MemberName经过修改的，不能用于英文版的显示
          if (structObj.memberNames) {
            MemberShowName = structObj.memberNames[i];
          } else {
            MemberShowName = structDesc[i][MemberNameIndex];
          }
        } else {
          MemberShowName = structDesc[i][MemberCnNameIndex];
        }
      }

      if (window.parseInt(structDesc[i][IsPrimaryKeyIndex], 10) === 1 || desc.unique) {
        primarryKeySym = "&nbsp;<label style='color:red;'>*</label>";
      } else {
        primarryKeySym = "";
      }

      if (valType >= 0) {
        html.push("<tr class='", odd_even, "'", trEvent, ">", //
          "<td class='paramNameTd' width='40%'>", MemberShowName, colon, "</td>", "<td width='60%'>", //
          getDiv(valType, desc), primarryKeySym, desc.Unit, "</td></tr>");
      }
    }

    return html.join("");
  }

  /**
   * 给竖表加上表头，表头是可选的，所有不集成在vTable里面
   */
  function vTableTitle() {
    return ["<tr><th width='40%' class='firstCell' >", top.T.ParamView.ParamsName, //
      "</th><th  width='60%' class='lastCell' >", top.T.ParamView.ParamsValue, "</th></tr>"].join("");
  }

  function getDiv(webType, desc) {
    return ["<div id='", desc.id, "' structName='", desc.structName, //
      "' memberType='", desc.memberType, "' style='display:inline;'>", createTags(webType, desc), "</div>"].join("");
  }

  /**
   * 创建标签
   * @param {Integer} webType，标签类型
   * @param {Object} desc，参数的描述信息
   */
  function createTags(webType, desc) {
    var type = window.parseInt(webType, 10), innerTag = [], i = 0, len = 0, //
      TypeDescIndex = top.c_paramRowIndex.TypeDesc, MemberIDIndex = top.c_paramRowIndex.MemberID, //
      memberID = Transfer.parseDbColumn(desc.structDesc[MemberIDIndex]), //
      typeDesc = Transfer.parseDbColumn(desc.structDesc[TypeDescIndex]), selectNames = [], selectVals = [], //
      optionArr = [], tmpArr = [], //
      notChangeablecss = ";background:#ffffff;opacity:0.4;filter:alpha(opacity=50);";
      if( desc.memberID == '4601901'||desc.memberID == '4601913' ||desc.memberID == '4601914'){//添加触发事件的回调，添加参数关联，主要用于mixViewPageSave.asp和lmtParamView.asp两个页面,当memberID为4601901（参数FrequencyBandIndicator）时,修改EARFCNDL的取值范围
          inputOnBlurEvent = " onmouseout='top.HTML.update(this,updateCallback)' onkeyup='top.HTML.update(this,updateCallback)' ";
      }else{
          inputOnBlurEvent = " onmouseout='top.HTML.update(this)' onkeyup='top.HTML.update(this)' ";
      }
      switch(type) {
      case -1:
        break;
      case 0:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;' type='text' structID='", desc.structID, //
          "' memberID='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", desc.proto, "' ", desc.tips, //
          inputOnBlurEvent, "/>");
        break;
      case 1:
        tmpArr = top.Transfer.wtListParser(typeDesc, memberID);
        selectNames = tmpArr.selectNames;
        selectVals = tmpArr.selectVals;

        innerTag.push("<select class='textInputSelect ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='height:20px;vertical-align:middle;' structID='", //
          desc.structID, "' memberID='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", desc.proto, "' onchange='top.HTML.update(this,updateCallback)'>");

        for (i = 0, len = selectNames.length; i < len; i += 1) {
          innerTag.push("<option value='", selectVals[i], "' title='", selectNames[i], "'>", selectNames[i], "</option>");
        }
        innerTag.push("</select>");
        break;
      case 2:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle; cursor:pointer;' onclick='showArray(this)' ", //
          " type='text' readonly='readonly' value='' structID='", desc.structID, "' memberID='", desc.memberID, //
          "' structName='", desc.structName, "' memberType='", desc.memberType, //
          "' proto='", desc.proto, "' onkeyup='top.HTML.update(this)'/>");
        break;
      case 3:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;' type='password' value='' structID='", //
          desc.structID, "' memberID='", desc.memberID, "' ", desc.tips, " structName='", //
          desc.structName, "' memberType='", desc.memberType, "' proto='", desc.proto, "'", //
          inputOnBlurEvent, "/>");
        break;
      case 4:
        tmpArr = top.Transfer.wtListParser(typeDesc, memberID);
        selectNames = tmpArr.selectNames;
        selectVals = tmpArr.selectVals;

        //selectNames = typeDesc.split(",");
        for (i = 0, len = selectNames.length; i < len; i += 1) {
          innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
            "' parentType='", desc.parentType, "' name='", desc.name, //
            "' style='vertical-align:middle; width:30px; border:none;background:transparent;' ", //
            " type='checkbox' value='", selectVals[i], "' alt='one' structID='", desc.structID, "' memberID='", desc.memberID, //
            "' structName='", desc.structName, "' memberType='", desc.memberType, //
            "' proto='", desc.proto, "' onclick='top.HTML.update(this)' />", selectNames[i], "&nbsp;&nbsp;");
          if ((i + 1) % 3 === 0 && i !== (selectNames.length - 1)) {
            innerTag.push("<br />");
          }
        }
        break;
      case 5:
        innerTag.push("<input class='", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;' type='button' value='查设' structID='", desc.structID, //
          "' memberID='", desc.memberID, "' structName='", desc.structName, "' memberType='", //
          desc.memberType, "' proto='", desc.proto, "' onkeyup='top.HTML.update(this)' onclick='showAddList(this)' />");
        break;
      case 6:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle; width:30px; border:none;background:transparent;' ", //
          " type='checkbox' value='0' alt='one' structID='", desc.structID, //
          "' memberID='", desc.memberID, "' id='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", desc.proto, "' onclick='top.HTML.update(this,updateCallback)' />", //
          "<label for='", desc.memberID, "'>", typeDesc, "</label>");
        break;
      case 7:
        innerTag.push("<a class='", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;' structID='", desc.structID, //
          "' memberID='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='' href ='#' onclick='top.HTML.update(this)'>", //
          typeDesc, "</a>");
        break;
      case 8:
        //*文本类型    不能用Label标签,Label在IE下无法赋值，在FF下换行有问题
        innerTag.push("<p class='textP ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;' structID='", desc.structID, //
          "' memberID='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", typeDesc, "'></p>");
        break;
      case 9:
        // BitMap类型
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle; cursor:pointer;' onclick='showBitMap(this)' ", //
          " type='text' readonly='readonly' value='' structID='", desc.structID, "' memberID='", desc.memberID, //
          "' structName='", desc.structName, "' memberType='", desc.memberType, //
          "' proto='", desc.proto, "' onkeyup='top.HTML.update(this)'/>");
        break;
      case 10:
        innerTag.push("<span intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;' type='text' structID='", desc.structID, //
          "' memberID='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", desc.proto, "'></span>");
        break;
      case 11:
        tmpArr = top.Transfer.wtListParser(typeDesc, memberID);
        selectNames = tmpArr.selectNames;
        selectVals = tmpArr.selectVals;

        innerTag.push("<select class='textInputSelect hide", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='height:20px;vertical-align:middle;", notChangeablecss, //
          "' structID='", desc.structID, "' memberID='", desc.memberID, //
          "' structName='", desc.structName, "' memberType='", desc.memberType, //
          "' proto='", desc.proto, "' disabled='disabled' >");
        for (i = 0, len = selectNames.length; i < len; i += 1) {
          innerTag.push("<option value='", selectVals[i], "' title='", selectNames[i], "'>", selectNames[i], "</option>");
        }
        innerTag.push("</select><span><span>");
        break;
      case 12:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, "' ", //
          "' style='vertical-align:middle; cursor:pointer;", notChangeablecss, //
          " type='text' readonly='readonly' value='' structID='", desc.structID, "' memberID='", desc.memberID, //
          "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", desc.proto, "' readonly='readonly'/>");
        break;
      case 13:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='vertical-align:middle;", notChangeablecss, //
          "' type='password' value='' structID='", //
          desc.structID, "' memberID='", desc.memberID, "' ", desc.tips, " structName='", //
          desc.structName, "' memberType='", desc.memberType, "' proto='", desc.proto, "' readonly='readonly'/>");
        break;
      case 14:
        selectNames = typeDesc.split(",");
        for (i = 0, len = selectNames.length; i < len; i += 1) {
          innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
            "' parentType='", desc.parentType, "' name='", desc.name, //
            "' style='vertical-align:middle; width:30px; border:none;background:transparent;' ", //
            " type='checkbox' value='0' alt='one' structID='", desc.structID, "' memberID='", desc.memberID, //
            "' structName='", desc.structName, "' memberType='", desc.memberType, //
            "' proto='", desc.proto, "' disabled='disabled'/>", "&nbsp;&nbsp;");
          if ((i + 1) % 3 === 0 && i !== (selectNames.length - 1)) {
            innerTag.push("<br />");
          }
        }
        break;
      case 15:
        innerTag.push("<div class='", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "'  name='", desc.name, "' style='vertical-align:middle;' ", //
          " structID='", desc.structID, "' memberID='", desc.memberID, "' structName='", //
          desc.structName, "' memberType='", desc.memberType, "' proto='", desc.proto, "' ></div>");
        break;
      case 16:
        innerTag.push("<input class='textInput ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' type='checkbox' value='0' alt='one'", //
          " style='vertical-align:middle; width:30px; border:none;background:transparent;' structID='", //
          desc.structID, "' memberID='", desc.memberID, "' id='", desc.memberID, //
          "' structName='", desc.structName, "' memberType='", desc.memberType, //
          "' proto='", desc.proto, "' disabled='disabled' /><label for='", desc.memberID, "'>", //
          typeDesc, "</label>");
        break;
      case 20:
        //下拉式数组类型（处理下拉选项，但是需要按照数组方式保存的参数）
        tmpArr = top.Transfer.wtListParser(typeDesc, memberID);
        selectNames = tmpArr.selectNames;
        selectVals = tmpArr.selectVals;

        innerTag.push("<select class='textInputSelect ", desc.typeclass, "' intanceIndex='", desc.row, //
          "' parentType='", desc.parentType, "' name='", desc.name, //
          "' style='height:20px;vertical-align:middle;' structID='", //
          desc.structID, "' memberID='", desc.memberID, "' structName='", desc.structName, //
          "' memberType='", desc.memberType, "' proto='", desc.proto, "' onchange='top.HTML.update(this,updateCallback)'>");

        for (i = 0, len = selectNames.length; i < len; i += 1) {
          innerTag.push("<option value='", selectVals[i], "' title='", selectNames[i], "'>", selectNames[i], "</option>");
        }
        innerTag.push("</select>");
        break;
    }
    return innerTag.join("");
  }

  /**
   * 元素值更新事件响应函数
   * @param {Object} node
   * @param {Object} structObj
   * @param {Function} callback
   */
  function update(node, callback) {
    var value = $(node).val(), structID = $(node).attr('structid'), //
      memberName = $(node).attr("name"), intanceindex = $(node).attr('intanceindex'), //
      webType = window.parseInt($(node).attr("memberType")), i = 0, len = 0;
    //添加该ClassIE7下出现鼠标移入，表格出现移动
    //$(node).removeClass("textInputActive");

    if (typeof (callback) !== "function") {
      callback = function () {
      };
    }

    switch (webType) {
      case 0:
        break;
      case 1:
        break;
      case 2:
        value = $(node).attr("proto");
        break;
      case 3:
        break;
      case 4:
        var result = [], inpObj = $(node).parent().children(), k = 0, tmplen = inpObj.length;
        for (k = 0; k < tmplen; k += 1) {
          if ($(inpObj[k]).is(":checked")) {
            result.push($(inpObj[k]).val());
          }
        }
        value = result.toString();
        break;
      case 5:
        value = $(node).attr("proto");
        break;
      case 6:
        value = "0";
        if ($(node).is(":checked")) {
          value = "1";
        }
        break;
      case 9:
        value = $(node).attr("proto");
        break;
      case 20:
        break;
      default:
        break;
    }

    CurrentStructs.update(node, structID, memberName, value, intanceindex);
    callback(node);
  }

  return {
    hTable: hTable,
    refreshHTable: refreshHTable,
    page: page,
    vTable: vTable,
    vTableTitle: vTableTitle,
    update: update,
    createWebTypeDesc: createWebTypeDesc,
    getDiv: getDiv,
	isAllHide:isAllHide
  };
}());
